(list key-w-face sep-w-face desc-w-face)))
unformatted)))
-(defun which-key--get-keymap-bindings (keymap)
+(defun which-key--get-keymap-bindings (keymap &optional filter)
"Retrieve top-level bindings from KEYMAP."
(let (bindings)
(map-keymap
(lambda (ev def)
- (cl-pushnew
- (cons (key-description (list ev))
- (cond ((keymapp def) "Prefix Command")
- ((symbolp def) (copy-sequence (symbol-name def)))
- ((eq 'lambda (car-safe def)) "lambda")
- (t (format "%s" def))))
- bindings :test (lambda (a b) (string= (car a) (car b)))))
+ (unless (and (functionp filter) (funcall filter ev def))
+ (cl-pushnew
+ (cons (key-description (list ev))
+ (cond ((keymapp def) "Prefix Command")
+ ((symbolp def) (copy-sequence (symbol-name def)))
+ ((eq 'lambda (car-safe def)) "lambda")
+ (t (format "%s" def))))
+ bindings :test (lambda (a b) (string= (car a) (car b))))))
keymap)
bindings))
(cons keymap-name keymap)))
(t (which-key--hide-popup)))))
-(defun which-key--show-keymap-no-intercept (keymap-name keymap)
- (setq which-key--current-prefix nil
- which-key--current-show-keymap-name keymap-name)
- (when (keymapp keymap)
- (let ((formatted-keys (which-key--get-formatted-key-bindings
- (which-key--get-keymap-bindings keymap))))
- (cond ((= (length formatted-keys) 0)
- (message "which-key: Keymap empty"))
- ((listp which-key-side-window-location)
- (setq which-key--last-try-2-loc
- (apply #'which-key--try-2-side-windows
- formatted-keys 0 which-key-side-window-location)))
- (t (setq which-key--pages-plist
- (which-key--create-pages formatted-keys (window-width)))
- (which-key--show-page 0)))))
- (let* ((key (key-description (list (read-key)))))
- (cond ((and which-key-use-C-h-commands (string= "C-h" key))
- (which-key-C-h-dispatch))
- (t (setq unread-command-events (listify-key-sequence key))
- (which-key--hide-popup)))))
+(defun which-key--evil-operator-filter (_ev def)
+ (and (functionp def)
+ (evil-get-command-property def :suppress-operator)))
+
+(defun which-key--show-evil-operator-keymap ()
+ (let ((keymap-name "evil operator state keys + motion keys")
+ (keymap
+ (make-composed-keymap (list evil-operator-shortcut-map
+ evil-operator-state-map
+ evil-motion-state-map))))
+ (setq which-key--current-prefix nil
+ which-key--current-show-keymap-name keymap-name)
+ (when (keymapp keymap)
+ (let ((formatted-keys (which-key--get-formatted-key-bindings
+ (which-key--get-keymap-bindings
+ keymap 'which-key--evil-operator-filter))))
+ (cond ((= (length formatted-keys) 0)
+ (message "which-key: Keymap empty"))
+ ((listp which-key-side-window-location)
+ (setq which-key--last-try-2-loc
+ (apply #'which-key--try-2-side-windows
+ formatted-keys 0 which-key-side-window-location)))
+ (t (setq which-key--pages-plist
+ (which-key--create-pages formatted-keys (window-width)))
+ (which-key--show-page 0)))))
+ (let* ((key (key-description (list (read-key)))))
+ (cond ((and which-key-use-C-h-commands (string= "C-h" key))
+ (which-key-C-h-dispatch))
+ (t (setq unread-command-events (listify-key-sequence key))
+ (which-key--hide-popup))))))
(defun which-key--create-buffer-and-show (&optional prefix-keys)
"Fill `which-key--buffer' with key descriptions and reformat.
((and which-key-show-operator-state-maps
(bound-and-true-p evil-state)
(eq evil-state 'operator))
- (which-key--show-keymap-no-intercept
- "evil operator state keys + motion keys"
- (make-composed-keymap (list evil-operator-shortcut-map
- evil-operator-state-map
- evil-motion-state-map))))
+ (which-key--show-evil-operator-keymap))
((and which-key--current-page-n
(not which-key--using-top-level)
(not which-key--current-show-keymap-name))